import exception.ageException;
import exception.numberException;
import function.InformationOperate;
import function.InformationOperateImpl;

import java.util.Scanner;

/**
 * @author LinLe
 * @create 2020-12-17 17:23
 */
public class StudentInfoSystem {
    private Scanner sn = new Scanner(System.in);
    private InformationOperate operate = new InformationOperateImpl();
    
    void start(){
        operate.inputInfo();
        System.out.println("---------------------------欢迎进入学生管理系统----------------------------");
        System.out.println("输入一下数字实现功能：");
        System.out.println("1: 增加学生信息" + "\n" + "2: 删除学生信息" +"\n" + "3: 修改学生信息"
                +"\n" + "4: 查找学生信息" + "\n" + "5: 获取全部学生信息" +"\n" + "0: 退出");
        System.out.print("请输入: ");
        int i = sn.nextInt();
        while(i != 0){
            switch (i){
                case 1:
                    try {
                        operate.add();
                    } catch (numberException e) {
                        e.printStackTrace();
                    } catch (ageException e) {
                        e.printStackTrace();
                    }
                    break;
                case 2: operate.delete();break;
                case 3:
                    try {
                        operate.change();
                    } catch (numberException e) {
                        e.printStackTrace();
                    } catch (ageException e) {
                        e.printStackTrace();
                    }
                    break;
                case 4: operate.find();break;
                case 5: operate.show();break;
                default:
                    System.out.println("无此功能，请重新输入");break;
            }
            System.out.println("输入一下数字实现功能：");
            System.out.println("1: 增加学生信息" + "\n" + "2: 删除学生信息" +"\n" + "3: 修改学生信息"
                    +"\n" + "4: 查找学生信息" + "\n" + "5: 获取全部学生信息" +"\n" + "0: 退出");
            System.out.print("请输入: ");
            i = sn.nextInt();
        }
        if(operate.getStu() != null){
            operate.outputInfo();
        }
       
   }
    public static void main(String[] args) {
        StudentInfoSystem system = new StudentInfoSystem();
        system.start();
    }
}
